#include <iostream>
#include <string>
using namespace std;

void permute(const string& pre, const string& pos){
	if(pos.size() == 0){
		cout << pre << endl;
		return;
	}
	for(size_t i = 0; i < pos.size(); ++i){
		string a = pre;
		string b = pos;
		char* c = new char(b[i]);
		permute(a.append(c), b.erase(i,1));
	}
}

void permute(const string& str){
	permute("", str);
}

int main(){
	permute("abc");
}
